package com.git.androidwy.UI.transform;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;

import androidx.annotation.Nullable;

public class TransformView extends View {
    private Paint mPaint = new Paint();
    public TransformView(Context context) {
        this(context, null);
    }

    public TransformView(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public TransformView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        mPaint.setColor(Color.rgb(200,150,160));
        mPaint.setAntiAlias(true);
        mPaint.setStrokeWidth(6);
        mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        //平移
        translation(canvas);
    }
    private void translation(Canvas canvas){
        canvas.save();
//        canvas.drawCircle(0,0,50,mPaint);
        canvas.translate(200,200);
        mPaint.setColor(Color.rgb(100,100,100));
        canvas.drawCircle(0,0,50,mPaint);
        canvas.restore();
        canvas.drawCircle(0,0,50,mPaint);
    }
}
